'''
author:mzy
time:11:11
date:2022/8/27
'''
from dubbo_test.path_opration import BASE_DIR
import json
import unittest
from  parameterized import parameterized
from dubbo_test.Script.methods import MemberService
from htmltestreport import HTMLTestReport

def select():
    with open(BASE_DIR+'/data/telephone.json','r',encoding="utf-8") as f:
        b = json.load(f)
    print(b)

    class FindByTelephon(unittest.TestCase):
        @parameterized.expand(b)
        def findbytelephone(self,t,d):
            print("t={} d={}".format(t,d))
            result = MemberService.find_by_telephone(t)
            print(result)
            self.assertEqual(d,result)

    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(FindByTelephon))
    path = BASE_DIR+'/report_HTML/FindByTelephon.html'
    my_runner = HTMLTestReport(path,"查询会员测试报告")
    my_runner.run(suite)

def add():
    with open(BASE_DIR+'/data/add.json','r',encoding="utf-8") as f:
        b = json.load(f)
    print(b)

    class Addvip(unittest.TestCase):
        @parameterized.expand(b)
        def addvip(self,i,n,n1,d):
            print("i={} n={} n1={}".format(i,n,n1))
            result = MemberService.add(i,n,n1)
            print(result)
            self.assertEqual(d,result)

    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(Addvip))
    path = BASE_DIR+'/report_HTML/Addvip.html'
    my_runner = HTMLTestReport(path,"增加会员测试报告")
    my_runner.run(suite)

